package com.googlecode.jvmpart.test;

import java.util.HashMap;
import java.util.Map;

import com.googlecode.jvmpart.ProcessExecution;
import com.googlecode.jvmpart.ProcessListener;
import com.googlecode.jvmpart.proc.JvmProcess;
import com.googlecode.jvmpart.support.JvmProcessPatitionHandler;
import com.googlecode.jvmpart.support.SimplePartitioner;

public class Flash8Partitioner extends SimplePartitioner implements ProcessListener {

	@Override
	public int getTotalProcessor() {
		return TOTAL;
	}
	private static final int TOTAL=20;
	private static final String URL_TEMPLATE="http://www6.flash8.net/fx/%d.shtml";
	@Override
	public Map<String, Object> processorParams(int index) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put(JvmProcess.PARAM_URL, String.format(URL_TEMPLATE, index+1));
		return map;
	}
	@Override
	public int getStartIndex() {
		return 240;
	}

	public static void main(String[] args) {
		JvmProcessPatitionHandler handler = new JvmProcessPatitionHandler(
				Flash8Processor.class, 5);
		try {
			Flash8Partitioner test = new Flash8Partitioner();
			handler.setProcessListener(test);
			handler.handle(test);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void beforeProcess(ProcessExecution threadExecution) {
		threadExecution.addVmArgument("-DproxyHost=PRCITD2ISA01Z10.cnintra.itd.net");
		threadExecution.addVmArgument("-DproxyPort=8088");
	}

	public void afterProcess(ProcessExecution threadExecution) {
		// TODO Auto-generated method stub
		
	}

}
